commit: Fix reading xattrs from OstreeRepoFile:s
authorAlexander Larsson <alexl@redhat.com>
Wed, 16 Nov 2016 21:46:45 +0000 (22:46 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 16 Nov 2016 22:30:33 +0000 (22:30 +0000)
When doing commit --tree=ref=XXX while at the same time applying some
form of modifier, ostree dies trying to read the xattrs using the
raw syscalls. We fix this by falling back to ostree_repo_file_get_xattrs()
in this case.

Also adds a testcase for this.

Closes: #577
Approved by: cgwalters

src/libostree/ostree-repo-commit.c
tests/basic-test.sh

index 7d78a19b3cbe14ec4857045cf311f1d0350bea88..6539c26b30b359bb925df55de1744475efb5c3f4 100644 (file)
@@ -2281,7 +2281,15 @@ get_modified_xattrs (OstreeRepo                       *self,
     }
   else if (!(modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS) > 0))
     {
-      if (path)
+      if (path && OSTREE_IS_REPO_FILE (path))
+        {
+          if (!ostree_repo_file_get_xattrs (OSTREE_REPO_FILE (path),
+                                            &ret_xattrs,
+                                            cancellable,
+                                            error))
+            goto out;
+        }
+      else if (path)
         {
           if (!glnx_dfd_name_get_all_xattrs (AT_FDCWD, gs_file_get_path_cached (path),
                                              &ret_xattrs, cancellable, error))
index 9db56e773b69ae2db15a626f031c67d49f8a45f0..ad70522acac7f0034a97f40fd0b6b5f5052c39b0 100755 (executable)
@@ -19,7 +19,7 @@
 
 set -euo pipefail
 
-echo "1..58"
+echo "1..59"
 
 $OSTREE checkout test2 checkout-test2
 echo "ok checkout"
@@ -178,6 +178,9 @@ echo "ok user checkout"
 $OSTREE commit -b test2 -s "Another commit" --tree=ref=test2
 echo "ok commit from ref"
 
+$OSTREE commit -b test2 -s "Another commit with modifier" --tree=ref=test2 --owner-uid=`id -u`
+echo "ok commit from ref with modifier"
+
 $OSTREE commit -b trees/test2 -s 'ref with / in it' --tree=ref=test2
 echo "ok commit ref with /"